package com.pg.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pg.entity.ycl.EipInsulationTorsion;
import com.pg.mapper.EipInsulationTorsionMapper;
import com.pg.service.EipInsulationTorsionService;
import com.pg.utils.Jpg2Base64Util;
import com.pg.utils.UploadFileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;


/**
 * <p>
 * 绝缘操作杆（扭杆） 服务实现类
 * </p>
 *
 * @Author likl
 * @since 2020-07-06
 */
@Service
@DS("proxyDs")
@Primary
public class EipInsulationTorsionServiceImpl extends ServiceImpl<EipInsulationTorsionMapper, EipInsulationTorsion> implements EipInsulationTorsionService {

    @Autowired
    private EipInsulationTorsionMapper eipInsulationTorsionMapper;

    @Override
    public void saveOne(EipInsulationTorsion insulationTorsion) {
        if (insulationTorsion.getCheckResult() != null) {
            String filePath = "/root/" + insulationTorsion.getCheckResult();
            insulationTorsion.setCheckResultObj(UploadFileUtils.uploadFiles(Jpg2Base64Util.Jpg2Base64(filePath)));
            eipInsulationTorsionMapper.insert(insulationTorsion);
        } else {
            insulationTorsion.setCheckResultObj(null);
            eipInsulationTorsionMapper.insert(insulationTorsion);
        }

    }
}
